package wusiyuan.servlet;

import java.io.IOException;
import javax.servlet.ServletException;
import javax.servlet.http.HttpServlet;
import javax.servlet.http.HttpServletRequest;
import javax.servlet.http.HttpServletResponse;
import javax.servlet.http.HttpSession;

import com.alibaba.fastjson.JSON;

import dao.CityDao;
import dao.impl.CityDaoImpl;
import entity.City;

/**
 * Servlet implementation class CityShowServlet
 */
public class CityShowServlet extends HttpServlet {
	private CityDao cd = new CityDaoImpl();
	protected void doGet(HttpServletRequest request, HttpServletResponse response) throws ServletException, IOException {
		
		response.setCharacterEncoding("utf-8");
		HttpSession session = request.getSession(); 
		Object object = session.getAttribute("city");
		int i = Integer.parseInt(object.toString());
		City city = cd.getCityByCityId(i);
		response.getWriter().print(JSON.toJSONString(city));
		
	}


	protected void doPost(HttpServletRequest request, HttpServletResponse response) throws ServletException, IOException {
		doGet(request, response);
	}

}
